package com.zjl.spring.pool;

import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicLong;

/**
 * @Auther: zhuangjl
 * @Date: 2021/11/16 16:02
 */
public class ThreadPoolTest {

    public static void main(String[] args) {

        ThreadPoolExecutor executors = new ThreadPoolExecutor(2, 8,
                10000L, TimeUnit.MILLISECONDS,
                new LinkedBlockingQueue<Runnable>(10000));

        executors.execute(new Runnable() {
            @Override
            public void run() {
                System.out.println("这种方式提交不会返回结果");
            }
        });

        Future<String> future = executors.submit(new Callable<String>() {
            @Override
            public String call() throws Exception {
                return "有返回值";
            }
        });
        try {
            String s = future.get();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }

        executors.shutdown();
        executors.shutdownNow();



    }
}
